﻿'Digite o NameSpace: Babok

<Serializable()> _
Public Class Impedimento
    Inherits BaseDominio

    Private _motivo As String
    Public Overridable Property Motivo() As String
        Get
            Return _motivo
        End Get
        Set(ByVal value As String)
            '_motivo = value
        End Set
    End Property

    Private _itemPriorizado As ItemPriorizado
    Public Overridable Property ItemPriorizado() As ItemPriorizado
        Get
            Return _itemPriorizado
        End Get
        Set(ByVal value As ItemPriorizado)
            '_itemPriorizado = value
        End Set
    End Property

    Private _status As StatusImpedimento
    Public Overridable Property Status() As StatusImpedimento
        Get
            Return _status
        End Get
        Set(ByVal value As StatusImpedimento)
            '_status = value
        End Set
    End Property


    Private _resolucao As String
    Public Overridable Property Resolucao() As String
        Get
            Return _resolucao
        End Get
        Set(ByVal value As String)
            '_resolucao = value
        End Set
    End Property


    Private _timeStamp As DateTime
    Public Overridable Property TimeStamp() As DateTime
        Get
            Return _timeStamp
        End Get
        Set(ByVal value As DateTime)
            '_timeStamp = value
        End Set
    End Property


#Region "Negocio"

    Public Sub New()
        MyBase.New()
    End Sub

    'Public Sub New(ByVal _motivo As String)
    '    MyBase.New()
    '    Me._motivo = _motivo
    'End Sub

    Public Overridable Function Buscar(ByVal _id As Long) As Impedimento
        Return MyBase.ImpedimentoDao.Buscar(_id)
    End Function

    Public Overridable Sub ResolverImpedimento(ByVal _resolucao As String)
        If String.IsNullOrEmpty(_resolucao) Then Throw New ImpedimentoException("Por favor, dê uma breve descrição da resolução fornecida.")
        Me._resolucao = _resolucao
        Me._status = StatusImpedimento.Resolvido
        Me.ImpedimentoDao.Alterar(Me)
    End Sub

    Public Overridable Sub Salvar(ByVal _itemPriorizado As ItemPriorizado, ByVal _motivo As String)
        If _itemPriorizado Is Nothing OrElse Not _itemPriorizado.Id.HasValue Then Throw New ImpedimentoException("Não é possível cadastrar um impedimento sem informar o ItemPriorizado ao qual o item pertence")
        If String.IsNullOrEmpty(_motivo) Then Throw New ImpedimentoException("Não é possível cadastrar um impedimento sem Motivo")
        Me._timeStamp = Now
        MyBase.ImpedimentoDao.Salvar(Me)
    End Sub

#End Region

End Class

